<script type="text/javascript">
    //上传图片完成回调
    function silder_pic_upload_success(file, data,$upload) {
        var json = $.parseJSON(data)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $upload.next().val(json.filename).next().html('<img src="'+ json.filename +'" width="80" />')
        }
    }

    //删除回调
    $('#silder').on('afterdelete.bjui.tabledit', function(e) {
        var $tbody = $(e.relatedTarget);
        console.log('你删除了一条数据，还有['+ $tbody.find('> tr').length +']条数据！');
        $("#pagerForm").alertmsg('ok', '删除成功！');
    })

    // 刷新数据
    function reloadTable(){
        $("#silder-reload").navtab('reloadForm', true);
    }

    // 点击编辑
    $(".edit-table-silder").click(function(){
        $(".table-show").addClass("hidden");
        $(this).parent().siblings().find(".table-show").removeClass("hidden");
    });

    // 双击表格
    $(".edit-tr-silder").dblclick(function(){
        $(".table-show").removeClass("hidden");
        $(this).siblings().find(".table-show").addClass("hidden");
    });

    // 点击添加幻灯
    $("#addSilder").click(function(){
        setTimeout("removeHidden()", 200);
    });

    /**
     * 添加时  去除隐藏
     */
    function removeHidden(){
        $("#tbodySilder tr:not(.edit-tr-link)").find(".table-show").removeClass("hidden");
    }
</script>
<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${ctxPath}/system/cms/ad/silder" method="post">
        <input type="hidden" name="pageSize" value="${model.pageSize!}">
        <input type="hidden" name="pageCurrent" value="${model.pageNum!}">
        <div class="bjui-searchBar">
            <button type="button" class="btn-green" id="addSilder" data-toggle="tableditadd" data-target="#silder" data-num="1" data-icon="plus" data-autorefresh="true">上传文件资料</button>&nbsp;
         </div>
    </form>
</div>
<div class="bjui-pageContent tableContent">
    <form id="silder_form" class="pageForm" data-toggle="validate" method="post">
        <table id="silder" class="table table-bordered table-hover table-top" data-toggle="tabledit"
               data-initnum="0" data-callback="reloadTable()" data-action="${ctxPath}/data/save" data-single-noindex="true">
            <thead>
            <tr style="text-align: center">
                <input type="hidden" name="type" value="2">
                <th align="center" title="编号">
                    <input type="text" name="id" placeholder="更新时填写资料id" title="默认为空，只有更新时才填写，新增时不填写" style="width: 50px">
                </th>
                <th align="center" title="资料名称">
                    <textarea style="height: 50px" name="dataTitle" data-rule="required;length(1~50)"></textarea>
                </th>
                <th align="center" title="资料简介">
                    <textarea rows="10" style="height: 50px" name="dataBrief" data-rule="required;length(1~500)"></textarea>
                </th>
                <th align="center" title="封面图片">
                    <div id="fileInput-[#index#]"
                         class="table-show hidden"
                         data-toggle="upload"
                         data-uploader="${ctxPath}/upload"
                         data-file-size-limit="1024000000"
                         data-file-type-exts="*.jpg;*.png;*.gif;*.mpg;"
                         data-multi="false"
                         data-on-upload-success="silder_pic_upload_success"></div>
                    <input type="hidden" name="dataCover"><span class="pic-box"></span>
                    <div>
                        <span style="color: darkgreen">（大小：1M以内，建议上传尺寸375*200，格式：jpg;png;gif;mpg）</span>
                    </div>
                </th>
                <th align="center" title="文件资料">
                    <div id="fileInput-[#index#]"
                         class="table-show hidden"
                         data-toggle="upload"
                         data-uploader="${ctxPath}/upload"
                         data-file-size-limit="40960000000"
                         data-file-type-exts="*.doc;*.docx;*.pdf;"
                         data-multi="false"
                         data-on-upload-success="silder_pic_upload_success"></div>
                    <input type="hidden" name="dataFile"><span class="pic-box"></span>
                    <div>
                        <span style="color: darkgreen">（大小：40M以内，格式：doc;docx;pdf）</span>
                    </div>
                </th>
                <th align="center" title="资料分类id"><input type="text" name="categoryId" data-rule="required;integer(+)" size="10"></th>
                <th align="center" title="资料分类名称"><input type="text" name="categoryName"  data-rule="required" value="" size="50"></th>
                <th align="center" title="操作" data-addtool="false" width="100">
                    <a href="javascript:void(0);" class="btn btn-green" data-toggle="dosave">保存</a>
                    <a href="javascript:void(0);" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删</a>
                </th>
            </tr>
            </thead>
            <tbody id="tbodySilder">
            @for(silde in model.list){
            <tr data-id="${silde.id!}" class="edit-tr-silder">
                <td align="center" data-noedit="true">${silde.id!}</td>
                <td align="center">${silde.sildeName!}</td>
                <td align="center" data-val="${silde.sildeUrl!}"></td>
                <td align="center">${silde.sortId!}</td>
                <!--<td  align="center" data-val="${silde.type!}" ></td>-->
                <td align="center" data-val="${silde.status!}"></td>
                <td align="center">
                    @if(isNotEmpty(silde.img)){
                    <span class="pic-box" style="margin-top:10px;">
                        <img data-rule="required" src="${silde.img!}" height="25" width="80">
                    </span>
                    @}
                </td>
                <td align="center" data-noedit="true">
                    <button type="button" class="btn-green edit-table-silder" data-toggle="doedit">编辑</button>
                    <a href="${ctxPath}/system/cms/ad/silder/delete?ids=${silde.id!}" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删</a>
                </td>
            </tr>
            @}
            </tbody>
        </table>
    </form>
</div>
<div class="bjui-pageFooter">
    <div class="pages">
        <span>每页&nbsp;</span>
        <div class="selectPagesize">
            <select data-toggle="selectpicker" data-toggle-change="changepagesize">
                <option value="30">30</option>
                <option value="60">60</option>
                <option value="120">120</option>
                <option value="150">150</option>
            </select>
        </div>
        <span>&nbsp;条，共 ${model.total!} 条</span>
    </div>
    <div class="pagination-box" data-toggle="pagination" data-total="${model.total!}" data-page-size="30" data-page-current="1">
    </div>
</div>